export {}
/**
  泛型
 */

/**
 1. 泛型别名
 掌握：泛型别名基本使用，实现类型复用
 */
// 用户信息接口
// 商品信息接口

// type UserData = {
//   code: number
//   message: string
//   data: {
//     id: string
//     name: string
//   }
// }

// type GoodsData = {
//   code: number
//   message: string
//   data: {
//     goods_id: string
//     goods_name: string
//     goods_price: number
//   }
// }

type User = {
  id: string
  name: string
}

type Goods = {
  goods_id: string
  goods_name: string
  goods_price: number
}

type Data<T> = {
  code: number
  message: string
  data: T
}

type UserData = Data<User>
type GoodsData = Data<Goods>

// ------------------------------
// -----------------------------

const user: UserData = {
  code: 1,
  message: '成功',
  data: {
    id: '10001',
    name: '张三'
  }
}

const goods: GoodsData = {
  code: 1,
  message: '成功',
  data: {
    goods_id: '10993',
    goods_name: '手机',
    goods_price: 999
  }
}